﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SMTC.Model.Model;
using SMTC.BO.BU;
using SMTC.WebCommon.Common;
using System.Web.UI.HtmlControls;
public partial class BaseInfoManagement_BUInfoMaintain : BasePage
{
    BUProccessServices proc = new BUProccessServices();

    protected override void OnPreRender(EventArgs e)
    {
        if (Request["action"] != null && Request["action"].ToString() == "select")
        {
            HtmlGenericControl tagBase = new HtmlGenericControl("base");
            tagBase.Attributes.Add("target", "_self");
            this.Page.Header.Controls.Add(tagBase);
        }
        base.OnPreRender(e);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request["action"] != null && Request["action"].ToString() == "select")
            {
                this.gvBUList.Columns[0].Visible = true;
                this.gvBUList.Columns[5].Visible = false;
                btnAdd.Visible = false;
                btnVendorContactOK.Visible = true;
                btnVendorContactCancel.Visible = true;
                title.Text = Resources.Resource.PleaseChooseBU; //"请选择BU";
                BUViewDataSource.SelectParameters.Add("sel", "1");

            }
            else
            {
                BUViewDataSource.SelectParameters.Add("sel", "0");
            }
        }
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        this.gvBUList.DataBind();
    }
    protected void gvBUList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Del")
        {
            if (proc.DeleteBU(e.CommandArgument.ToString()))
            {
                ShowMessage(Resources.Resource.LineInfoDeleteSuccess);//生产线删除成功！
            }
            else
            {
                ShowMessage(Resources.Resource.LineInfoDeleteFailed);//生产线删除失败！
            }
        }
    }
}